package com.yu.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yutao
 * @date 2021/10/18 23:06
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRrouteLocator(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route_yu",r -> r.path("/guonei") //我们用ip:端口/guonei  就会访问到下面那个uri
                .uri("https://news.baidu.com/guonei")).build();
        return routes.build();

    }

    @Bean
    public RouteLocator customRrouteLocator2(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route_guoji",r -> r.path("/guoji") //我们用ip:端口/guonei  就会访问到下面那个uri
                .uri("https://news.baidu.com/guoji")).build();
        return routes.build();

    }



}
